import { ReactNode } from 'react';
import Table from './table';

export default function Op<T>(idfieldname: keyof T, render: (record: T) => ReactNode, width?: string) {
	const field = idfieldname as string;
	return <Table.Column<T> title='操作' key={field} width={width} dataIndex={field} align='center' render={(_value, record) => {
		const id = record[idfieldname] as unknown as string;
		return <div className='op' key={id}>{render(record)}<style jsx>{`
.op{
	margin: 0;
	display: flex;
	justify-content: space-around;
	align-items: center;
	width: 100%;
	height: 1rem;
	flex-wrap: nowrap;
}
`}</style></div>;
	}} />;
}
